package GUI;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.imageio.ImageIO;

import gra.Card;

public class VirtualCard 
{
    Card[] cards;
    Image[] cardImages;
    File[] sciezkiKart;
    
    VirtualCard( Card[] karty ) throws IOException
    {
        cards       = new Card[5];
        cardImages  = new Image[5];
        sciezkiKart = new File[5];
        
        for( int i = 0; i < 5; i++ )
        {
            try
            {
                cards[i]       = karty[i];
                sciezkiKart[i] = new File( "images/karta"+cards[i].value+cards[i].colour+".png" );
                cardImages[i]  = ImageIO.read( sciezkiKart[i] );
            }catch( NullPointerException e )
            {
                System.out.println("Brak odpowiedniej karty");
            }
        }
    }
    
    public void ustawKarty( Card[] karty ) throws IOException
    {
        for( int i = 0; i < 5; i++ )
        {
            try
            {
                cards[i]       = karty[i];
                sciezkiKart[i] = null;
                sciezkiKart[i] = new File( "images/karta"+cards[i].value+cards[i].colour+".png" ); 
                cardImages[i]  = ImageIO.read( sciezkiKart[i] );
            }catch( NullPointerException e )
            {
                System.out.println("Brak odpowiedniej karty");
            }
        }
    }
}
